<template>
  <div>
    <p>账号：<input type="text" v-model="form.username"></p>
    <p>密码：<input type="text" v-model="form.password"></p>
    <button @click="login">登录</button>
  </div>
</template>

<script>
export default {
  name: "xpy_login",
  data() {
    return {
      form: {}
    }
  },
  methods: {
    login() {
      this.$axios.post('users/banji/', this.form)
        .then(res => {
          if (res.data.code == 200) {
            alert('登录成功')
            localStorage.setItem('userid', res.data.userid)
            this.$router.push('/show_xpy')
          } else {
            alert('登录失败')
          }
        })
    }
  }
}
</script>

<style scoped>

</style>
